using Gtk;
using System;

namespace Serpis
{
	public static class NotebookExtensions
	{
		public static void AddTab(this Notebook notebook, IListView listView) {
			notebook.AddTab((Widget)listView, listView.GetType().GetLabel());
		}
		
		public static void AddTab(this Notebook notebook, Widget widget, string label) {
			widget.Visible= true;
			HBox hBox = new HBox();
			Label gtkLabel = new Label(label);
			gtkLabel.Visible= true;
			hBox.Add(gtkLabel);
			Button button = new Button();
			button.Image = Image.NewFromIconName(Stock.Close, IconSize.Button);
			button.Visible= true;
			hBox.Add(button);
			
			button.Clicked += delegate {
				notebook.Remove(widget);
			};
			
			notebook.AppendPage(widget, hBox);
		}
	}
}

